<%@page import="model.Muctintuc"%>
<%@page import="java.sql.Time"%>
<%@page import="java.sql.Date"%>
<%@page import="form.ConnectionDB"%>
<%@page import="java.sql.ResultSet"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<jsp:include page="Admin_includes/header.jsp"></jsp:include>
<style type="text/css">
.xoa {
	text-indent: -99999px;
	width: 28px;
	height: 23px;
	background: url("Admin_images/xoa.png") no-repeat center;
	border: none;
}

.sua {
	text-indent:-99999px;
	width:28px;
	height:23px;
	background:url("Admin_images/sua.png");
	border: none;
}
</style>
<div id="center-content">
	<div id="left">
		<jsp:include page="Admin_includes/left.jsp"></jsp:include>
	</div>
	<!-- end left -->







	<div id="right">
		<a href="Admin_tintuc.jsp" class="btlink">Danh sách tin tức</a> <a
			href="Admin_themtintuc.jsp" class="btlink">Thêm tin tức</a>
		<fieldset>
			<table class="table1" width="740">
				<legend> Danh sách tin tức</legend>
				<tr>
					<th>Tintuc-id</th>
					<th>Hình</th>
					<th>Title</th>
					<th>Muctintuc-id</th>
					<th>Ngày Viết</th>
					<th>Sukien-id</th>
					<th>Nội dung</th>
					<th>Sửa</th>
					<th>Xóa</th>
				</tr>
				<%
					String sql = "select * from tintuc";
					String sukien = "",err="";
					Muctintuc muctintuc = new Muctintuc();
					int muctintuc_id = muctintuc.getIdmuctintuc();

					ResultSet rs = null;
					try{
					rs = ConnectionDB.getConnection().createStatement()
							.executeQuery(sql);
					while (rs.next()) {
						int tintuc_id = rs.getInt("tintuc_id");
						String hinh = rs.getString("hinh");
						String title = rs.getString("title");
						muctintuc_id = rs.getInt("muctintuc_id");
						Date ngayviet = rs.getDate("ngayviet");
						String sukien_id = rs.getString("sukien_id");
						if (sukien_id == null) {
							sukien = "Không có sự kiện";
						} else {
							sukien = sukien_id;
						}
						String noidung = rs.getString("noidung");
				%>
				<tr>
					<td><%=tintuc_id%></td>
					<td><img src="<%=hinh%>" width="30" height="30"></td>
					<td><%=title%></td>
					<td><%=muctintuc_id%></td>
					<td><%=ngayviet%></td>
					<td><%=sukien%></td>
					<td class="noidung" style="padding: 2px;">
						<form>
							<textarea name="" cols="" rows="" readonly
								style="width: 150px; height: 40px;"><%=noidung%></textarea>

						</form>

					</td>
					
					<td class="suaxoa"><form action="Admin_suathanhvien.jsp" method="post"><input 
						type="submit" value="<%=tintuc_id%>" name="email" class="sua"  title="Sửa"/></form>
				</td>


				<td class="suaxoa"><form action="xoathanhvien" method="post">

						<input type="submit" onclick="return confirmAction()"
							value="<%=tintuc_id%>" name="email" class="xoa" title="Xóa"/>

					</form></td>
				</tr>
				<%
					}
				%>
				<%
					}catch(Exception e){
						err="Hệ thống chưa kết nối cơ sở dữ liệu!Chúng tôi sẽ nhanh chóng khắc phục!";
					}
				%>

			</table>
		</fieldset>
	</div>
	<label style="color:#EE2C2C; font-size: 18px; font-weight: bold;"><%=err%></label>
	<!-- end right -->




</div>
<!-- end center-content-->
<jsp:include page="Admin_includes/footer.jsp"></jsp:include>